#ifndef __WAV_H__
#define __WAV_H__

/* Audio file information structure */
typedef struct
{
	rt_uint32_t  RIFFchunksize;
	rt_uint16_t  FormatTag;
	rt_uint16_t  NumChannels;
	rt_uint32_t  SampleRate;
	rt_uint32_t  ByteRate;
	rt_uint16_t  BlockAlign;
	rt_uint16_t  BitsPerSample;
	rt_uint32_t  DataSize;
} WAVE_FormatTypeDef;

/* Error Identification structure */
typedef enum
{
	Valid_WAVE_File = 0,
	Unvalid_RIFF_ID,
	Unvalid_WAVE_Format,
	Unvalid_FormatChunk_ID,
	Unsupporetd_FormatTag,
	Unsupporetd_Number_Of_Channel,
	Unsupporetd_Sample_Rate,
	Unsupporetd_Bits_Per_Sample,
	Unvalid_DataChunk_ID,
	Unsupporetd_ExtraFormatBytes,
	Unvalid_FactChunk_ID
} ErrorCode;

/* Private typedef -----------------------------------------------------------*/
typedef enum
{
	LittleEndian,
	BigEndian
}Endianness;

/* Private define ------------------------------------------------------------*/

/* Audio file header size */
#define HEADER_SIZE          100


/* Uncomment this line to enable verifying data sent to codec after each write opeation */
//#define VERIFY_WRITTENDATA

/* The 7 bits Codec adress mask */
#define CODEC_ADDRESS         0x27  /* b00100111 */ 

/* Audio Parsing Constants */
#define  ChunkID             0x52494646  /* correspond to the letters 'RIFF' */
#define  FileFormat          0x57415645  /* correspond to the letters 'WAVE' */
#define  FormatID            0x666D7420  /* correspond to the letters 'fmt ' */
#define  DataID              0x64617461  /* correspond to the letters 'data' */
#define  FactID              0x66616374  /* correspond to the letters 'fact' */

#define  WAVE_FORMAT_PCM     0x01
#define  FormatChunkSize     0x10
#define  Channel_MONO        0x01
#define  Channel_STEREO      0x02

#define  SampleRate_8000     8000
#define  SampleRate_16000    16000
#define  SampleRate_22050    22050
#define  SampleRate_44100    44100
#define  SampleRate_48000    48000
#define  Bits_Per_Sample_8   8
#define  Bits_Per_Sample_16  16

#define DUMMY_DATA           0x1111

ErrorCode I2S_CODEC_WaveParsing(rt_uint8_t* HeaderTab, WAVE_FormatTypeDef  *WAVE_Format);

#endif
